import mongoose from 'mongoose';

//连接数据库
const connectDB = async ()=>{
    try{
        const conn = await mongoose.connect(process.env.MONGO_URI,{
            useUnifiedTopology:true,
            useNewUrlParser:true,
            useCreateIndex:true,
        });
        console.log(`MongoDB 已连接：${conn.connection.host}`);
    }catch(err){
        console.log(`Error：${err.message}`);
        process.exit(1);
    }
};

export default connectDB;